<template>
  <div>
    <el-table :data="data.tableData" stripe border height="150" style="width:800px">
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="age" label="年龄"></el-table-column>
      <el-table-column prop="sex" label="性别"></el-table-column>
      <el-table-column label="其他操作">
        <template #default="scope">
          <el-button @click="deleteData(scope.$index)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { reactive } from "vue";

const data = reactive({
  tableData: [
    {
      name: "田阿成",
      age: "3",
      sex: "男",
    },
    {
      name: "郭娜娜",
      age: "4",
      sex: "女",
    },
    {
      name: "杨敏",
      age: "5",
      sex: "女",
    },
    {
      name: "赵辉印",
      age: "2",
      sex: "男",
    },
  ],
});
const deleteData = (index) => {
  data.tableData.splice(index, 1);
};
</script>

<style lang="less" scoped></style>
